package main

import (
	"fmt"
	"sync/atomic"
)

func main() {
	var b atomic.Bool
	b.Store(true)
	if b.CompareAndSwap(true, false) {
		fmt.Println("true 111 ", b.Load())
	} else {
		fmt.Println("false 222", b.Load())
	}

	i := int32(10)

	if atomic.CompareAndSwapInt32(&i, 10, 11) {
		fmt.Println("spwaped: ", i)
	} else {
		fmt.Println("not swaped: ", i)
	}
}
